<?php

namespace App\Models;

use Dcat\Admin\Traits\ModelTree;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;


class Device extends Model
{
    use ModelTree;
    protected $table = 'xfy_device';
    protected $primaryKey = 'deviceId';

    protected $titleColumn = 'devicename';

    protected $orderColumn = 'sort';

    protected $parentColumn = 'pid';

    protected $fillable = ['devicename', 'projectId', 'pid', 'wk_box_id','wk_group_id', 'device_type'];

    // 返回空值即可禁用 order 字段
    public function getOrderColumn()
    {
        return null;
    }
    // public function user(){
    // 	return $this->belongsTo(User::class,'user_id','id');
    // }
    // 
    public function points()
    {
        return $this->hasMany(DevicePoint::class, 'device_id');
    }
}